package com.example.anju.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.example.anju.entity.Information;


@Mapper
@Repository
public interface InformationMapper {
	// 根据ID查看个人信息
	@Select("SELECT * FROM information WHERE information_user_id=#{information_user_id}")
	List<Information> findInformationById(@Param("information_user_id") int information_user_id);

	// 修改个人信息
	@Insert("UPDATE information SET name=#{name},sex=#{sex},age=#{age},id_card=#{id_card},phone=#{phone} WHERE information_user_id=#{information_user_id}")
	void postInformationById(Information information);

	// 创建个人信息
	@Insert("INSERT INTO information VALUES(#{information_id},#{information_user_id},#{name},#{sex},#{age},#{phone},#{id_card})")
	@Options(useGeneratedKeys = true, keyProperty = "information_id", keyColumn = "information_id")
	void newInformationById(Information information);
}
